//
//  ILScrollViewManger.m
//  Products_B
//
//  Created by lanou on 16/5/29.
//  Copyright © 2016年 朋学友. All rights reserved.
//

#import "ILScrollViewManger.h"

@interface ILScrollViewManger ()<UIScrollViewDelegate>
@property(nonatomic,strong)UIScrollView *scrollView;
@property(nonatomic,assign)int index;
@end

@implementation ILScrollViewManger

-(void)SetScrollViewWithFrame:(CGRect)frame viewController:(UIView *)viewControll ImageLabelWithimageArray:(NSArray *)array titleTextArray:(NSArray *)TitleArray detailTextArray:(NSArray *)detailArray tapAction:(TapBlock)tapBlock{

    self.index = 0;
    self.tapBlock = tapBlock;

    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kWidth, frame.size.height)];
    self.scrollView.delegate = self;
    self.scrollView.contentSize = CGSizeMake(frame.size.width / 4 * array.count, frame.size.height);//设置整个轮播图的偏移Frame
    self.scrollView.contentOffset = CGPointMake(0, 0);
//    self.scrollView.pagingEnabled = YES;//整页翻转
    self.scrollView.bounces = NO;//边界回弹
    self.scrollView.showsHorizontalScrollIndicator = NO;//横向水平条显示
    self.scrollView.showsVerticalScrollIndicator = NO;//纵向水平条显示
    self.scrollView.backgroundColor = [UIColor whiteColor];
   
    [viewControll addSubview:_scrollView];
    
    for (int i = 0; i < array.count; i++) {
            
        _imageLabel = [[imageLabel alloc] initWithFrame:CGRectMake(frame.size.width / 4 * i, 0, frame.size.width / 4, frame.size.height - 20) image:array[i] text:TitleArray[i] text2:[NSString stringWithFormat:@"%@", detailArray[i]] index:i tapAction:^(int index){
            
            self.index = index;
            self.tapBlock(self.index);
        }];
        [self.scrollView addSubview:_imageLabel];
            
    }

}




@end
